home *** CD-ROM | disk | FTP | other *** search
Wrap
/* File: GraphicsStateLibrary.c Contains: graphics libraries - graphics state routines Written by: Cary Clark, Georgiann Delaney, Michael Fairman, Dave Good, Robert Johnson, Keith McGreggor, Mike Reed, Oliver Steele, David Van Brink, Chris Yerga Copyright: © 1995 by Apple Computer, Inc., all rights reserved. Change History (most recent first): <1> 1/9/95 JD First checked in. */ #include <Memory.h> #include "GraphicsLibraries.h" #include "GraphicsStateLibrary.h" graphicsState lastGraphicsState = nil; graphicsState NewGraphicsState(void) { graphicsState state = (graphicsState) NewPtr(sizeof(graphicsStateRecord)); short i; IfErrorReturnNil(state == nil, out_of_memory); for (i = gxEmptyType; i <= gxPictureType; i++) state->defaultShapes[i - 1] = GXGetDefaultShape(i); return lastGraphicsState = state; } void DisposeGraphicsState(graphicsState state) { NilParamReturn(state); if (lastGraphicsState == state) lastGraphicsState = nil; DisposePtr((Ptr) state); } void GetGraphicsState(graphicsState state) { short i; NilParamReturn(state); for (i = gxEmptyType; i <= gxPictureType; i++) { gxShape def = GXGetDefaultShape(i); if (state->defaultShapes[i - 1] != def) { GXDisposeShape(state->defaultShapes[i - 1]); state->defaultShapes[i - 1] = def; } } } void SetGraphicsState(graphicsState state) { short i; NilParamReturn(state); for (i = gxEmptyType; i <= gxPictureType; i++) GXSetDefaultShape(state->defaultShapes[i - 1]); lastGraphicsState = state; } graphicsState SwapGraphicsState(graphicsState state) { graphicsState lastState = lastGraphicsState; if (lastGraphicsState) SetGraphicsState(lastGraphicsState); if (state) SetGraphicsState(state); lastGraphicsState = state; return lastState; } gxStyle SeparateShapeStyle(gxShape source) { gxStyle old = GXCloneStyle(GXGetShapeStyle(source)), xnew = GXCopyToStyle(nil, old); GXSetShapeStyle(source, xnew); GXDisposeStyle(xnew); return old; } void ReuniteShapeStyle(gxShape target, gxStyle separate) { GXSetShapeStyle(target, separate); GXDisposeStyle(separate); return; } gxInk SeparateShapeInk(gxShape source) { gxInk old = GXCloneInk(GXGetShapeInk(source)), xnew = GXCopyToInk(nil, old); GXSetShapeInk(source, xnew); GXDisposeInk(xnew); return old; } void ReuniteShapeInk(gxShape target, gxInk separate) { GXSetShapeInk(target, separate); GXDisposeInk(separate); return; }